<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start();

class mainpage extends CI_Controller 
	{
		function index()
		{
			$this->load->model("idea_model");
			
			$data['main_idea'] = $this->idea_model->getMainIdea(); 
			$data['premiums'] = (array)$this->idea_model->getPremiums();//get premium ideas
			$data['most_viewed'] = (array)$this->idea_model->getMostViewed();//get most viewed ideas
			$data['most_bump'] = (array)$this->idea_model->getMostBump();//get most bump ideas
			
			if(isset($_SESSION['userObject'])){
				//if user is logged in
				$user = $_SESSION['userObject'];
				
				if(strlen($user->user_interests) > 2){
					//if interest data is present, explode to array
					$interests = explode(";", $user->user_interests);
					
					$interests = explode(";", $user->user_interests);
					//get idea by interest
				
					$data['interest'] = (array)$this->idea_model->getIdeaByInterest($interests);
				}
				
			}
			
			$this->load->view('view_main', $data);
			
		}
	}
?>
		